package com.twu.biblioteca;

import java.util.ArrayList;
import java.util.List;

public class Books {
    private List<Book> bookList = new ArrayList<Book>();

    public void add(Book book) {
        bookList.add(book);
    }

    public String showBooks() {
        StringBuilder sb = new StringBuilder();
        sb.append("Book list:");
        for (Book book : bookList) {
            sb.append("\n" + book.name());
        }
        return sb.toString();
    }

    public boolean contains(String bookName) {
        for (Book book : bookList) {
            if(book.name().equals(bookName)){
                return true;
            }
        }
        return false;
    }

    public Book getBook(String name) {
        for (Book book : bookList) {
            if(book.name().equals(name)){
                return book;
            }
        }
        return null;
    }
}
